#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10, M = 31 * N;
int arr[N];
int tree[M][2];
int idx;
int n;
void insert(int x)
{
	int p = 0;
	for (int i = 30; i >= 0; i--) {
		int s = x >> i & 1;
		if (!tree[p][s]) {
			tree[p][s] = ++idx;
		}
		p = tree[p][s];
	}
}
int query(int x)
{
	int p = 0;
	int ans = 0;
	for (int i = 30; i >= 0; i--) {
		int s = x >> i & 1;
		if (tree[p][!s]) {
			p = tree[p][!s];
			ans = ans * 2 + 1;
		}
		else {
			p = tree[p][s];
			ans = ans * 2;
		}
	}
	return ans;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		insert(arr[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, query(arr[i]));
	}
	cout << ans << endl;
	return 0;
}